<template>
  <div id="street-view">
    <img src="http://115.159.66.213:8000/guess.png" alt="">
    <div class="container">
      <img src="http://115.159.66.213:8000/reminder1.png" alt="">
      <p>_____学校,{{college.simpleInfo}}</p>
      <img src="http://115.159.66.213:8000/reminder2.png" alt="">
      <iframe :src="college.streetView[0]"
              height="500"
              width="1100"
              frameborder="0"
              scrolling="0"
      ></iframe>
      <img src="http://115.159.66.213:8000/reminder3.png" alt="">
      <iframe :src="college.streetView[1]"
              height="500"
              width="1100"
              frameborder="0"
              scrolling="0"
      ></iframe>
    </div>
    <img src="http://115.159.66.213:8000/answer.png" alt="" class="answer">
    <div class="answer1">
      <div class="text">上述描述高校是_____?</div>
    </div>
    <div class="answer2">
      <input type="text" v-model="answer">
      <el-button class="button" :disabled="isDisabled" @click="isUniversity">确认</el-button>
    </div>
  </div>
</template>

<script>
  import {colleges} from "../../assets/js/college";

  export default {
    name: "StreetView",
    data() {
      return {
        answer: '',
        isDisabled: true,
        college: {},
      }
    },
    watch: {
      answer() {
        if (this.answer === '') {
          this.isDisabled = true
        } else {
          this.isDisabled = false
        }
      }
    },
    created() {
      this.college = colleges[Math.round(Math.random() * 6)]
    },
    methods:{
      isUniversity(){
        if(this.answer===this.college.name){
          this.$message({
            message: '恭喜你，小天才，猜对了，再来一题吧！！！',
            type: 'success'
          });
          this.answer=''
          this.college = colleges[Math.round(Math.random() * 6)]
        }else{
          this.$message({
            message: '不好意思，你猜错了！！！',
            type: 'error'
          });
          this.answer=''
        }
      }
    }
  }
</script>

<style scoped>
  #street-view {
    height: 100%;
    background-color: #ffffff;
    text-align: center;
  }

  .container {
    height: 70%;
    margin: 0 300px;
    padding: 50px 50px;
    opacity: 0.95;
    text-align: left;
    overflow: auto;
  }

  p {
    line-height: 26px;
    text-indent: 3em;
    margin-top: 20px;
    margin-bottom: 20px;
  }

  iframe {
    margin-top: 20px;
    margin-bottom: 20px;
  }

  .answer {
    position: fixed;
    top: 230px;
    right: 100px;
  }

  .answer1 {
    position: fixed;
    right: 50px;
    top: 300px;
    width: 200px;
    height: 150px;
    border: 2px solid #6566ae;
    border-bottom: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    background-color: #f1f3f4;

  }

  .answer2 {
    position: fixed;
    right: 50px;
    top: 450px;
    width: 200px;
    height: 150px;
    border: 2px solid #ef292f;
    border-top: 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    background-color: #f1f3f4;
  }

  .text {
    margin-top: 70px;
  }

  .answer2 input {
    box-sizing: border-box;
    height: 30px;
    padding: 10px;
    border-radius: 7px;
    text-align: center;
    border-top: 1px solid #6566ae;
    border-bottom: 1px solid #ef292f;
  }

  .button {
    margin-top: 20px;
    border: 1px solid #ef292f;
  }

</style>